import { defineStore } from 'pinia';
import { local } from '@/utils';

export const useRoleStore = defineStore('userRole', {
    state: () => ({
        roles: <string[]>[],
        permissions: <string[]>[]
    }),
    getters: {
        getRoles(): string[] {
            return this.roles;
        },
        getPermissions(): string[] {
            return this.permissions;
        }
    },
    actions: {
        setRoles(ids: string[]): void {
            this.roles = ids;
            local.set('roles', ids);
        },
        setPermissions(ids: string[]): void {
            this.permissions = ids;
            local.set('permissions', ids);
        }
    }
});
